@use 'sass:list';
@use 'sass:map';

@use '@material/button/button-outlined-theme' as mdc-button-outlined-theme;
@use '@material/button/button-protected-theme' as mdc-button-protected-theme;
@use '@material/button/button-filled-theme' as mdc-button-filled-theme;
@use '@material/button/button-text-theme' as mdc-button-text-theme;
@use '@material/card/elevated-card-theme' as mdc-elevated-card-theme;
@use '@material/card/outlined-card-theme' as mdc-outlined-card-theme;
@use '@material/checkbox/checkbox-theme' as mdc-checkbox-theme;
@use '@material/circular-progress/circular-progress-theme' as mdc-circular-progress-theme;
@use '@material/fab/extended-fab-theme' as mdc-extended-fab-theme;
@use '@material/fab/fab-theme' as mdc-fab-theme;
@use '@material/linear-progress/linear-progress-theme' as mdc-linear-progress-theme;
@use '@material/icon-button/icon-button-theme' as mdc-icon-button-theme;
@use '@material/list/list-theme' as mdc-list-theme;
@use '@material/tooltip/plain-tooltip-theme' as mdc-plaintip-tooltip-theme;
@use '@material/radio/radio-theme' as mdc-radio-theme;
@use '@material/switch/switch-theme' as mdc-switch-theme;
@use '@material/tab-indicator/tab-indicator-theme' as mdc-tab-indicator-theme;
@use '@material/tab/tab-theme' as mdc-tab-theme;
@use '@material/snackbar/snackbar-theme' as mdc-snackbar-theme;
@use '@material/slider/slider-theme' as mdc-slider-theme;
@use '@material/chips/chip-theme' as mdc-chips-theme;
@use '@material/dialog/dialog-theme' as mdc-dialog-theme;
@use '@material/textfield/filled-text-field-theme' as mdc-filled-text-field-theme;
@use '@material/textfield/outlined-text-field-theme' as mdc-outlined-text-field-theme;
@use '@material/form-field/form-field-theme' as mdc-form-field-theme;
@use '@material/theme/validate' as mdc-validate;

@use '../m2/mdc/protected-button' as tokens-mdc-protected-button;
@use '../m2/mdc/filled-button' as tokens-mdc-filled-button;
@use '../m2/mdc/text-button' as tokens-mdc-text-button;
@use '../m2/mdc/outlined-button' as tokens-mdc-outlined-button;
@use '../m2/mdc/circular-progress' as tokens-mdc-circular-progress;
@use '../m2/mdc/linear-progress' as tokens-mdc-linear-progress;
@use '../m2/mdc/elevated-card' as tokens-mdc-elevated-card;
@use '../m2/mdc/icon-button' as tokens-mdc-icon-button;
@use '../m2/mdc/checkbox' as tokens-mdc-checkbox;
@use '../m2/mdc/extended-fab' as tokens-mdc-extended-fab;
@use '../m2/mdc/fab' as tokens-mdc-fab;
@use '../m2/mdc/list' as tokens-mdc-list;
@use '../m2/mdc/outlined-card' as tokens-mdc-outlined-card;
@use '../m2/mdc/plain-tooltip' as tokens-mdc-plain-tooltip;
@use '../m2/mdc/radio' as tokens-mdc-radio;
@use '../m2/mdc/switch' as tokens-mdc-switch;
@use '../m2/mdc/tab-indicator' as tokens-mdc-tab-indicator;
@use '../m2/mdc/tab' as tokens-mdc-tab;
@use '../m2/mdc/snack-bar' as tokens-mdc-snack-bar;
@use '../m2/mdc/slider' as tokens-mdc-slider;
@use '../m2/mdc/chip' as tokens-mdc-chip;
@use '../m2/mdc/dialog' as tokens-mdc-dialog;
@use '../m2/mdc/filled-text-field' as tokens-mdc-filled-text-field;
@use '../m2/mdc/outlined-text-field' as tokens-mdc-outlined-text-field;
@use '../m2/mdc/form-field' as tokens-mdc-form-field;

@mixin validate-slots($component, $slots, $reference) {
  @debug 'Validating #{$component}...';
  // We don't care what the values are, just that every valid token is present in the slots map.
  // Specifically its ok if the token is explicitly mapped to `null`. We therefore replace all the
  // token values with true to prevent the validation function from complaining about the explicit
  // `null` tokens being missing.
  @each $token, $_ in $slots {
    $slots: map.set($slots, $token, true);
  }
  $x: mdc-validate.theme-styles($reference, $slots);
}

@include validate-slots(
  $component: 'm2.mdc.list',
  $slots: tokens-mdc-list.get-token-slots(),
  $reference: mdc-list-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.circular-progress',
  $slots: tokens-mdc-circular-progress.get-token-slots(),
  $reference: mdc-circular-progress-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.icon-button',
  $slots: tokens-mdc-icon-button.get-token-slots(),
  $reference: mdc-icon-button-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.elevated-card',
  $slots: tokens-mdc-elevated-card.get-token-slots(),
  $reference: mdc-elevated-card-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.outlined-card',
  $slots: tokens-mdc-outlined-card.get-token-slots(),
  $reference: mdc-outlined-card-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.checkbox',
  $slots: tokens-mdc-checkbox.get-token-slots(),
  $reference: mdc-checkbox-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.linear-progress',
  $slots: tokens-mdc-linear-progress.get-token-slots(),
  $reference: mdc-linear-progress-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.plain-tooltip',
  $slots: tokens-mdc-plain-tooltip.get-token-slots(),
  $reference: mdc-plaintip-tooltip-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.radio',
  $slots: tokens-mdc-radio.get-token-slots(),
  $reference: mdc-radio-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.switch',
  $slots: tokens-mdc-switch.get-token-slots(),
  $reference: mdc-switch-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.tab-indicator',
  $slots: tokens-mdc-tab-indicator.get-token-slots(),
  $reference: mdc-tab-indicator-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.tab',
  $slots: tokens-mdc-tab.get-token-slots(),
  $reference: mdc-tab-theme.$secondary-light-theme
);
@include validate-slots(
  $component: 'm2.mdc.snackbar',
  $slots: tokens-mdc-snack-bar.get-token-slots(),
  $reference: mdc-snackbar-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.slider',
  $slots: tokens-mdc-slider.get-token-slots(),
  $reference: mdc-slider-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.chips',
  $slots: tokens-mdc-chip.get-token-slots(),
  $reference: mdc-chips-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.dialog',
  $slots: tokens-mdc-dialog.get-token-slots(),
  $reference: mdc-dialog-theme.$light-theme
);
// Note: we should validate the `fab-small` here as well, but MDC doesn't expose its light theme.
@include validate-slots(
  $component: 'm2.mdc.fab',
  $slots: tokens-mdc-fab.get-token-slots(),
  $reference: mdc-fab-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.extended-fab',
  $slots: tokens-mdc-extended-fab.get-token-slots(),
  $reference: mdc-extended-fab-theme.$extended-light-theme
);
@include validate-slots(
  $component: 'm2.mdc.filled-text-field',
  $slots: tokens-mdc-filled-text-field.get-token-slots(),
  $reference: mdc-filled-text-field-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.outlined-text-field',
  $slots: tokens-mdc-outlined-text-field.get-token-slots(),
  $reference: mdc-outlined-text-field-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.filled-button',
  $slots: tokens-mdc-filled-button.get-token-slots(),
  $reference: mdc-button-filled-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.protected-button',
  $slots: tokens-mdc-protected-button.get-token-slots(),
  $reference: mdc-button-protected-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.text-button',
  $slots: tokens-mdc-text-button.get-token-slots(),
  $reference: mdc-button-text-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.outlined-button',
  $slots: tokens-mdc-outlined-button.get-token-slots(),
  $reference: mdc-button-outlined-theme.$light-theme
);
@include validate-slots(
  $component: 'm2.mdc.form-field',
  $slots: tokens-mdc-form-field.get-token-slots(),
  $reference: mdc-form-field-theme.$light-theme
);
